package com.coding.kan_yi_dao.controller;


import com.coding.kan_yi_dao.common.Result;
import com.coding.kan_yi_dao.entity.AdminUser;
import com.coding.kan_yi_dao.service.impl.AdminUserServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 砍一刀，不买就砍你一刀
 * @since 2023-09-20
 */
@Api(tags = "后台管理")
@RestController
@RequestMapping("/admin_user")
@CrossOrigin
public class AdminUserController {
    @Resource
    AdminUserServiceImpl adminUserService;

    //TODO 后台登入
    @ApiOperation(value = "后台登入")
    @GetMapping("/goLogin")
    public Result goLogin(AdminUser adminUser) {
        return adminUserService.gologin(adminUser);
    }

    //TODO 修改密码
    @ApiOperation(value = "修改密码")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "adminPassword", value = "旧密码"),
            @ApiImplicitParam(name = "new_adminPassword",value = "新密码"),
            @ApiImplicitParam(name = "adminId",value = "编号")
})
    @GetMapping("/go_update_password")
    public Result go_update_password(Integer adminId,String adminPassword, String new_adminPassword) {
        return adminUserService.go_update_password(adminId,adminPassword,new_adminPassword);
    }

    //TODO 前端测试
    @ApiOperation(value = "前台测试")
    @GetMapping("/gotest")
    public Result gotest(){
        return adminUserService.gotest();
    }
}
